﻿namespace EFS.RC.Wallboard.Controls.Endpoints.Customer
{
	public partial class Main : System.Windows.Controls.UserControl
	{
		#region Locals
		/// customerEndPoint
		private EFS.RC.CC.Messages.Application.CustomerEndPoint customerEndPoint = null;
		#endregion

		public Main()
		{
			InitializeComponent();
		}

		#region Properties
		/// Property CustomerEndPoint: Get, Set
		public EFS.RC.CC.Messages.Application.CustomerEndPoint CustomerEndPoint
		{
			get
			{
				return customerEndPoint;
			}
			set
			{
				// check
				EFS.Common.Verify.Reference(value, "customerEndPoint");

				// keep
				this.customerEndPoint = value;

				// set config phone
				this.ConfigPhone = EFS.RC.Wallboard.Common.Config.Sections.Phones.All.Instance[value.PhoneUri];
				EFS.Common.Verify.Reference(this.ConfigPhone, "this.ConfigPhone");

				// set profiles
				controlPhoneNumber.NumberContainerImageSource = EFS.Common.UI.Resources.ImageSource.Cache.GetSource(this.ConfigPhone.Profile.Resources.ImageTelContainer);
				controlFirstGroup.HourglassImageSource = EFS.Common.UI.Resources.ImageSource.Cache.GetSource(this.ConfigPhone.Profile.Resources.ImageHourglass);
				controlSecondGroup.PieSlicedImageSource = EFS.Common.UI.Resources.ImageSource.Cache.GetSource(this.ConfigPhone.Profile.Resources.ImagePieSliced);
				controlSecondGroup.Profile = this.ConfigPhone.Profile.CallStatistic;
				controlThirdRow.RingImageSource = EFS.Common.UI.Resources.ImageSource.Cache.GetSource(this.ConfigPhone.Profile.Resources.ImageRing);
				controlThirdRow.Profile = this.ConfigPhone.Profile.AgentStatus;

				// set text
				controlPhoneNumber.Number = this.customerEndPoint.PhoneUri;
			}
		}

		/// Property ConfigPhone: Get, Set
		public EFS.RC.Wallboard.Common.Config.Sections.Phones.Phone ConfigPhone { get; private set; }
		#endregion

		#region LoadData
		/// Property LoadData: Get, Set
		public void LoadData(EFS.RC.CC.Messages.Agents.StatusList statusListMsg)
		{
			// FREE
			EFS.RC.CC.Messages.Agents.Status[] statusArrayFREE =
				statusListMsg.Filter(null, true, false, null, true, CustomerEndPoint.RequiredSkillId, true, CustomerEndPoint.PhoneUri);

			// LOGGED_IN
			EFS.RC.CC.Messages.Agents.Status[] statusArrayLOGGED_IN =
				statusListMsg.Filter(null, true, null, null, true, CustomerEndPoint.RequiredSkillId, true, CustomerEndPoint.PhoneUri);

			// BUSY
			EFS.RC.CC.Messages.Agents.Status[] statusArrayBUSY =
				statusListMsg.Filter(null, true, true, null, null, CustomerEndPoint.RequiredSkillId, true, CustomerEndPoint.PhoneUri);

			EFS.RC.CC.Messages.Agents.Status[] statusArrayIN_WRAP =
				statusListMsg.Filter(null, true, null, true, null, CustomerEndPoint.RequiredSkillId, true, CustomerEndPoint.PhoneUri);

			// set
			controlThirdRow.Free = statusArrayFREE.Length;
			controlThirdRow.LoggedIn = statusArrayFREE.Length + statusArrayBUSY.Length;
			controlThirdRow.Busy = statusArrayBUSY.Length;
			controlThirdRow.InWrap = statusArrayIN_WRAP.Length;
		}

		#endregion
	}

}